<%@include file="/WEB-INF/pages/commons/commons.jsp"%>


<c:set var="title" value="Blog - ${actionBean.blog.name}" scope="request" />
<c:set var="name" value="${actionBean.blog.name}" scope="request"/>
<c:set var="description" value="${actionBean.blog.description}" scope="request" />

<stripes:layout-render name="${_blogThemePath}/blog_layout.jsp" _title="${title}" _blogName="${name}" _blogDescription="${description}">

    <stripes:layout-component name="_head">${_head}</stripes:layout-component>

    <stripes:layout-component name="_content">
        <c:forEach items="${actionBean.entries.list}" var="currentEntry" varStatus="status">
            <h1>${currentEntry.name}</h1>
            <p><span class="radeox">${currentEntry.decoratedContent}</span></p>
            <br/>
            <div class="meta">
                <p class="byline">
                    Created on <fmt:formatDate value="${currentEntry.creationDate}" pattern="dd-MM-yyyy hh:mm:ss" />
                    Published on <fmt:formatDate value="${currentEntry.publishDate}" pattern="dd-MM-yyyy hh:mm:ss"/>
                    by <c:out value="${currentEntry.creator.username}"/>
                </p>
				<p class="links">
                    <stripes:link class="more" beanclass="foo.bar.blog.web.action.general.BlogActionBean" event="viewEntry">
                        <stripes:param name="entry" value="${currentEntry.id}"/>
                        <stripes:param name="blog" value="${currentEntry.blog.id}"/>
                        Read full article
                    </stripes:link>
                    <b>|</b>
                    <stripes:link class="comments" beanclass="foo.bar.blog.web.action.general.BlogActionBean" event="viewEntry">
                        <stripes:param name="entry" value="${currentEntry.id}"/>
                        <stripes:param name="blog" value="${currentEntry.blog.id}"/>
                        Comments (<c:out value="${currentEntry.totalComments}"/>)
                    </stripes:link>
                </p>
            </div>
            <br/>
        </c:forEach>

        <!-- paging -->
        <hr/>
        <div class="meta">
            <!-- previous -->
            <c:choose>
            <c:when test="${actionBean.entries.anyPreviousPage}">
                <stripes:link beanclass="foo.bar.blog.web.action.general.BlogActionBean" event="view">
                    <c:choose>
                        <c:when test="${actionBean.selectedTag == null}">
                            <stripes:param name="selectedTag" value="null"/>
                        </c:when>
                        <c:otherwise>
                            <stripes:param name="selectedTag" value="${actionBean.selectedTag.id}" />
                        </c:otherwise>
                    </c:choose>
                    <stripes:param name="blog" value="${blog.id}"/>
                    <stripes:param name="pageNumber" value="${actionBean.entries.pageNumber - 1}"/>
                    Previous<b>|</b>
                </stripes:link>
            </c:when>
            <c:otherwise>
                Previous<b>|</b>
            </c:otherwise>
            </c:choose>

            <!-- pages -->
            <c:forEach begin="1" end="${actionBean.entries.totalPages}" step="1" var="currentPage" varStatus="status">
                <c:choose>
                    <c:when test="${actionBean.entries.pageNumber eq currentPage}">
                        <c:out value="${currentPage}"/><b>|</b>
                    </c:when>
                    <c:otherwise>
                        <stripes:link beanclass="foo.bar.blog.web.action.general.BlogActionBean" event="view">
                            <c:choose>
                                <c:when test="${actionBean.selectedTag == null}">
                                    <stripes:param name="selectedTag" value="null"/>
                                </c:when>
                                <c:otherwise>
                                    <stripes:param name="selectedTag" value="${actionBean.selectedTag.id}" />
                                </c:otherwise>
                            </c:choose>
                        <stripes:param name="blog" value="${blog.id}"/>
                        <stripes:param name="pageNumber" value="${currentPage}"/>
                        <c:out value="${currentPage}"/><b>|</b>
                        </stripes:link>
                    </c:otherwise>
                </c:choose>
            </c:forEach>


            <!-- next -->
            <c:choose>
                <c:when test="${actionBean.entries.anyNextPage}">
                    <stripes:link beanclass="foo.bar.blog.web.action.general.BlogActionBean" event="view">
                    <c:choose>
                        <c:when test="${actionBean.selectedTag == null}">
                            <stripes:param name="selectedTag" value="null"/>
                        </c:when>
                        <c:otherwise>
                            <stripes:param name="selectedTag" value="${actionBean.selectedTag.id}" />
                        </c:otherwise>
                    </c:choose>
                    <stripes:param name="blog" value="${blog.id}"/>
                    <stripes:param name="pageNumber" value="${actionBean.entries.pageNumber + 1}"/>
                    Next
                    </stripes:link>
                </c:when>
                <c:otherwise>
                    Next
            </c:otherwise>
            </c:choose>
        </div>
    </stripes:layout-component>
</stripes:layout-render>

